import axios from "axios";

const SpecsStory ={
    namespaced: true,
    state:()=>({
        Specs_list:[],
        count:0
    }),
    mutations:{
        SpecsMutation(state,list){
            state.Specs_list =list
        },
        SpecsMutation_count(state,num){
            state.count =num
        }
    },
    actions:{
        SpecsAction(context,page={page:1,page_size:1}){
            var url = "/specslist?page="+page.page+"&size="+page.page_size
            axios.get(url).then(
                res=>{

                    if(res.code == 403){
                        localStorage.removeItem('log_list')
                        window.location.href = "/#/login"
                       
                    }else{
                         context.commit('SpecsMutation',res.list)
                    }
                   
                }
            )
        },
        SpecsAction_count(context){
            axios.get('/specscount').then(
                res=>{
                    context.commit('SpecsMutation_count',res.list[0].total)
                }
            )
        }

    }

}
export default SpecsStory